package main

import (
	"flag"
	"fmt"
	"gitee.com/gomod/utils/logger"
	"learn-land-crawler/app/config"
	"learn-land-crawler/app/job"
	"learn-land-crawler/app/model"
	routers "learn-land-crawler/app/router"
	"strconv"
)

func main() {
	env := flag.String("env", "local", "环境配置，生产:prod，测试:test，开发:dev，本地：local")
	flag.Parse()
	fmt.Printf("run by environment: %s\n", *env)
	config.Profile = *env
	config.InitConfig(*env)
	// 日志
	logger.InitLogger(config.LoggerConfig.Filepath)
	// Init DB
	model.InitDB()
	// 定时任务
	job.InitTasks()
	// 路由初始化
	e := routers.Init()
	if err := e.Run(":" + strconv.Itoa(config.ServerConfig.Port)); err != nil {
		fmt.Printf("startup biz failed, err: %v", err)
	}
}
